
/**
 *
 * @param 筛选项
 * @param screen
 * @returns
 */


export const OtherOutSearchSelect =  (value: string, screen:any)=>{
  const {
    categoryList, //买方
    transport_type, //运输方式
    settle_type, //付款方式
    invoice_type,//发票类型
    creator, //创建人
    invoice_str, //发票抬头
    settle_organization, //卖方
  } = screen

  if (value == 'buyer_customer_id' && categoryList) {
    return categoryList.map((item:any)=>{
      return {
        ...item,
        value: item.uid,
        label: item.name,
      }
    })
  }

  if (value == 'invoice_type' && invoice_type) {
    return [
      { value: '1', label: '增值税专用发票' },
      { value: '2', label: '普通发票' },
      { value: '3', label: '不需要开票' },
    ]
  }

  if (value == 'transport_type' && transport_type) {
    return transport_type.map((item:any)=>{
      return {
        ...item,
        value: item.uid,
        label: item.name,
      }
    })
  }
  if (value == 'pay_type' && settle_type) {
    return [
      { value: '1', label: '运费到付' },
      { value: '2', label: '运费预付' },
    ]
  }

  if (value == 'status') {
    return [
      { value: '0', label: '草稿' },
      { value: '1', label: '已提交' },
      { value: '2', label: '已取消' },
      { value: '3', label: '已完成' },
    ]
  }

  if (value == 'orderTrack_status') {
    return [
      { value: '0', label: '草稿' },
      { value: '1', label: '已提交' },
      { value: '2', label: '已取消' },
      { value: '110', label: '卖方已接收' },
      { value: '120', label: '卖方已下单' },
      // { value: '130', label: '已确认' },
      { value: '140', label: '待付款' },
      { value: '150', label: '已付款' },
      { value: '160', label: '已出库' },
      { value: '170', label: '已发出' },
      { value: '180', label: '部分出库' },
      { value: '190', label: '部分发出' },
      { value: '3', label: '已完成' },
    ]
  }

  if (value == 'create_user_id' && creator) {
    return creator.map((item:any)=>{
      return {
        ...item,
        value: item.create_user_id,
        label: item.create_user_name,
      }
    })
  }

  if (value == 'invoice_str' && invoice_str) {
    return creator.map((item:any)=>{
      return {
        ...item,
        value: item.create_user_id,
        label: item.create_user_name,
      }
    })
  }
  if (value == 'after_sale') {
    return [
      { value: '0', label: '未出库' },
    ]
  }

  if (value == 'sales_org_name' && settle_organization) {
    return settle_organization.map((item:any)=>{
      return {
        ...item,
        value: item.sales_org_name,
        label: item.sales_org_name,
      }
    })
  }

  return []
}

/**
 *
 * @param OrderStatus
 * @returns
 */
export const OrderStatus = (value: string | number, info = {})=>{
  if (value == '-1') return '删除'
  if (value == '0') return '草稿'
  if (value == '1') return '已提交'
  if (value == '2') return '已取消'
  if (value == '3') return '确认收货'
  return '--'
}

/**
 *
 * @param OrderTrackStatus
 * @returns
 */
export const OrderTrackStatus = (value: string | number, info = {})=>{
  const list =  OtherOutSearchSelect('orderTrack_status', '')
  const row = list.filter((item:any)=>  item.value == value)
  return  row && row[0] ? row[0].label : '--'
}

/**
 * @查询页面
 */
export const CheckSearch = [
  {  label: '需求编号', prop: 'order_no', type: 'input' },
  {  label: '买方', prop: 'buyer_customer_id', type: 'select', multiple: true },
  {  label: '需求状态', prop: 'status', type: 'select', multiple: true },
  {  label: '采购数量', prop: 'product_num', type: 'range' },
  // {  label: '产品名称', prop: 'product_code', type: 'lazySelect', multiple: true },
  {  label: '创建日期', prop: 'create_time', type: 'time' },
  {  label: '创建人', prop: 'create_user_id', type: 'select', multiple: true },
]

export const CheckCloums = [
  { label: '需求编号', prop: 'order_no', width: '160', type: 'custom' },
  { label: '需求状态', prop: 'status', width: '100', type: 'custom'},
  { label: '买方', prop: 'buyer_customer_name' },
  { label: '采购数量', prop: 'product_num', width: '120', type: 'number' },
  // { label: '发票抬头', prop: 'invoice_str' },
  { label: '收货地址', prop: 'address', width: '280'},
  { label: '创建人', prop: 'create_user_name', width: '100'},
  { label: '创建时间', prop: 'create_at', width: '120', type: 'time' },
]

/**
 * @订单详情
 */
export const DetailBase = [
  {  label: '买方', prop: 'buyer_customer_name', type: 'select', required: true },
  {  label: '开票类型', prop: 'invoice_type_str', type: 'select', required: false },
  {  label: '发票抬头', prop: 'invoice_str', type: 'input', required: true },
  {  label: '公司税号', prop: 'tax_number', type: 'input', required: true },
  {  label: '期望运输方式', prop: 'transport_type_str', type: 'select', required: false },
  {  label: '运费付款方式', prop: 'pay_type', type: 'select', required: false },
  {  label: '收货地址', prop: 'shipping_address', type: 'address', required: true },
  {  label: '详细地址', prop: 'address', type: 'input', required: true },
  {  label: '收货联系人', prop: 'shipping_contact', type: 'input', required: true },
  {  label: '联系电话', prop: 'shipping_tel', type: 'input', required: true },
]
export const DetailCloums = [
  { label: '品牌', prop: 'brand', width: '240' },
  { label: '产品条码', prop: 'product_barcode', width: '140'},
  { label: '产品名称', prop: 'product_name' },
  { label: '产品类型', prop: 'goods_type', width: '120' },
  { label: '规格', prop: 'specification', width: '120' },
  { label: '采购数量', prop: 'number', width: '160', type: 'number' },
  { label: '备注', prop: 'remark', },
]

// 详情赠品
export const detailGiftColumns = [
  { label: '品牌', prop: 'brand', width: '240'  },
  { label: '赠品编码', prop: 'product_code',  width: '140'  },
  { label: '赠品名称', prop: 'product_name',   },
  { label: '数量', prop: 'number', width: '160', type: 'number' },
  { label: '赠品类型', prop: 'goods_type', width: '120' },
  { label: '备注', prop: 'remark', },
]

/**
 * @订单创建
 */
export const OrderCreateLeft = [
  {  label: '买方', prop: 'buyer_customer_id', type: 'select_buyer', required: true },
  {  label: '开票类型', prop: 'invoice_type', type: 'select', required: true },
  {  label: '发票抬头', prop: 'invoice_str', type: 'input', required: true },
  // {  label: '公司税号', prop: 'tax_number', type: 'input', required: true },
  // selectCreate
  {  label: '期望运输方式', prop: 'transport_type', type: 'select', required: true },
  {  label: '运费付款方式', prop: 'pay_type', type: 'select', required: true, isAdd: false },
  {  label: '期望到货时间', prop: 'arrival_time', type: 'input', required: false, },

]
export const OrderCreateRight = [
  {  label: '收货地址', prop: 'identify_address', type: 'identify', required: false },
  {  label: '收货地址', prop: 'shipping_address', type: 'address', required: true },
  {  label: '详细地址', prop: 'address', type: 'input', required: true },
  {  label: '收货联系人', prop: 'shipping_contact', type: 'input', required: true },
  {  label: '联系电话', prop: 'shipping_tel', type: 'input', required: true },
]

/**
 * @订单跟踪
 */

export const orderTrackSearch = [
  { label: '订单编号', prop: 'order_no', type: 'input' },
  { label: '订单流转状态', prop: 'orderTrack_status', type: 'select', multiple: true },
  { label: '卖方', prop: 'sales_org_name', type: 'select', multiple: true },
  { label: '买方', prop: 'buyer_customer_id', type: 'select', multiple: true },
  { label: '产品名称', prop: 'product_code', type: 'lazySelect', multiple: true },
  { label: '采购金额', prop: 'order_price', type: 'range' },
  // { label: '售后状态', prop: 'after_sale', type: 'select', multiple: true },
  // { label: '发票抬头', prop: 'invoice_str', type: 'select', multiple: true },
  { label: '创建日期', prop: 'create_time', type: 'time' },
  { label: '创建人', prop: 'create_user_id', type: 'select', multiple: true },
]

export const orderTrackCloums = [
  { label: '订单编号', prop: 'order_no', width: '150', type: 'custom' },
  { label: '订单流转状态', prop: 'order_status_str', width: '120', type: 'custom' },
  { label: '买方', prop: 'buyer_customer_name' },
  { label: '需求数量', prop: 'product_num', type: 'number', width: '100', isShort: true, shortName: 'product_num' },
  { label: '实际采购数量', prop: 'ordered_num', type: 'number', width: '120', isShort: true, shortName: 'sales_num' },
  { label: '采购金额', prop: 'selling_price', type: 'money', width: '100', isShort: true, shortName: 'amount' },
  // { label: '发票抬头', prop: 'invoice_str', width: '240' },
  // { label: '收货地址', prop: 'shipping_address', width: '200' },
  // { label: '卖方', prop: 'mf', width: '100' },
  { label: '卖方商务', prop: 'undertaker_name', width: '100' },
  // { label: '售后状态', prop: 'after_sale', width: '100', type: 'custom' },
  { label: '创建人', prop: 'create_user_name', width: '100' },
  { label: '创建时间', prop: 'create_at', width: '180' },
]

/**
 * @订单跟踪详情
 */

export const OrderTrackDateilBase = [
  {  label: '买方', prop: 'buyer_customer_name', type: '' },
  {  label: '收货地址', prop: 'shipping_address', type: '' },
  {  label: '开票类型', prop: 'invoice_type_str', type: '' },
  {  label: '详细地址', prop: 'address', type: '' },
  {  label: '发票抬头', prop: 'invoice_str', type: '' },
  {  label: '收货联系人', prop: 'shipping_contact', type: '' },
  {  label: '期望运输方式', prop: 'transport_type_str', type: '' },
  {  label: '联系电话', prop: 'shipping_tel', type: '' },
  {  label: '运费付款方式', prop: 'pay_type', type: '' },
  {  label: '公司税号', prop: 'tax_number', type: '' },
]

export const OrderTrackDateilProductCloums = [
  { label: '品牌', prop: 'brand', width: '240' },
  { label: '产品条码', prop: 'product_barcode', width: '140'},
  { label: '产品名称', prop: 'product_name' },
  { label: '产品类型', prop: 'goods_type', width: '120' },
  { label: '规格', prop: 'specification', width: '120' },
  { label: '采购数量', prop: 'number', width: '160', type: 'number' },
  { label: '备注', prop: 'remark', },
]

// 赠品策略类型
export const strategyList = [
  { value: '正品', label: '正品' },
  { value: '赠品', label: '赠品' },
  { value: '样品', label: '样品' },
]
// 赠品
export const giftColumns = [
  { label: '产品类型', prop: 'goods_type', width: '160'},
  { label: '产品编码', prop: 'number', width: '200' },
  { label: '产品名称', prop: 'name'},
  { label: '品牌', prop: 'assistant_name' , width: '160'},
  { label: '数量', prop: 'buy_number',  type: 'number', width: '200'},
  { label: '备注', prop: 'remark', width: '310' },
]

